<?php
require_once("lib/db_connection.php");

 $company_id = $_SESSION['company_id'];
 $veh_id = $_GET['veh'];
 
 $result_comp = mysql_query("SELECT * FROM company_tbl WHERE company_id='".$company_id."'")
 or die("SELECT COMPANY ".mysql_error());
 $row_comp = mysql_fetch_array($result_comp);

 $query_journal = "SELECT tire_id, location, description, axle, wheel, tread, date, comments FROM tire_srvcejournal_tbl
 WHERE vehicle_id='".$veh_id."' ORDER BY journal_id DESC";
 $result_journal = mysql_query($query_journal) or die('LIST JOURNAL '.mysql_error());
 
 $query_vehicles = "SELECT * FROM vehicle_tbl WHERE vehicle_id='".$veh_id."'";
 $result_vehicles = mysql_query($query_vehicles) or die("VEHICLES ".mysql_error());
 $row_vehicles = mysql_fetch_array($result_vehicles);
 
 
?>
<html>
<head>
<script type='text/javascript'>
function print_doc()
{
	window.print();
}
</script>
</head>
<body onload='print_doc()'>
<table border='0' width='810' style='font-size:14px;font-family:Times New Roman'>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['company_name']?></th>
</tr>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['address']?></th>
</tr>
<tr>
 <td width='33%' style='text-align:left;'>Contact No:<?php echo $row_comp['contact_no']?></td>
 <td width='34%' style='text-align:center;'><?php echo $row_comp['website']?></td>
 <td width='33%' style='text-align:right;'>Fax No:<?php echo $row_comp['fax_no']?></td>
</tr>
</table>
<img border="0" src="image/report_tire_history.png" width="810" height="30" />
<table border='0' width='810' style='font-size:14px;font-family:Times New Roman'>
<tr>
  <td width='50%' style='text-align:left;'><b>Veh:<?php echo $row_vehicles['veh_num']?></b>
  &nbsp;&nbsp;<b><?php echo $row_vehicles['year']?>&nbsp;<?php echo $row_vehicles['manufacturer_name']?>&nbsp;<?php echo $row_vehicles['model_name']?></b>
  </td>
 </tr>
</table>
<br/>
<table border='1' width='810' style='font-size:14px;font-family:Times New Roman'>
 <tr>
  <td style='text-align:center;width:14%'>DATE</td>
  <td style='text-align:center;width:35%'>DESCRIPTION</td>
  <td style='text-align:center;width:14%'>BRAND</td>
  <td style='text-align:center;width:12%'>POSITION</td>
  <td style='text-align:center;width:25%'>REMARKS</td>
 </tr>
 <?php
 while($row_jou = mysql_fetch_array($result_journal))
 {
 $tire_id = $row_jou['tire_id'];

 $query_tire = "SELECT manufacturer FROM tire_inventory_tbl WHERE tire_id='".$tire_id."'";
 $result_tire = mysql_query($query_tire) or die('select tire'.mysql_error());
 $row_tire = mysql_fetch_array($result_tire);
 ?>
 <tr>
  <td style='text-align:center;width:14%'>&nbsp;<?php echo $row_jou['date']?>&nbsp;</td>
  <td style='text-align:center;width:35%'>&nbsp;<?php echo $row_jou['description']?>&nbsp;</td>
  <td style='text-align:center;width:14%'>&nbsp;<?php echo $row_tire['manufacturer']?>&nbsp;</td>
  <td style='text-align:center;width:12%'>&nbsp;<?php echo $row_jou['location']?>&nbsp;</td>
  <td style='text-align:center;width:25%'>&nbsp;<?php echo $row_jou['comments']?>&nbsp;</td>
 </tr>
 <?php
 }
 ?>
</table>
<br/>
<p style=" position: relative; bottom: 0; left: 0; width: 100%; text-align: center;"><img border="0" src="image/footer_wo.png" width="135" height="30" /></p>
</body>
</html>